
import ICapability from 'components/capability/interfaces/ICapability';
import { Element } from 'components/Three';
import * as THREE from 'three';
import Controller from 'Controller';
import React from 'react';

/** 点光源 */
export const pointLight: ICapability<undefined> = {
    id: 'pointLight',
    title: '点光源',
    useExpand: () => {

        const onClick = React.useCallback(() => {
            const threeController = Controller.instance.state.threeController;
            const light = new THREE.PointLight( 0xffffff, 1, 100 );

            light.shadow.camera.far = 1000;
            light.shadow.bias = -0.001;
            light.position.set(0, 0, 0);
            light.castShadow = true;

            const element = new Element('light', light.uuid, light)
            threeController.sceneAdd(element);
            threeController.run(async s => s.selectedElementUuid = element.uuid);
        }, [])

        return {
            onClick,
        }
    }
}